package com.tedu.openmedical.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class Util {

    //将字符串转换为SimpleDateFormat定制日期
    public static Date strToDate(String dateStr, String dateFormat) {
        try {
            // 定义日期格式
            SimpleDateFormat format = new SimpleDateFormat(dateFormat);
            return format.parse(dateStr);
        } catch (ParseException e) {
            // 处理解析异常
            e.printStackTrace();
        }
        return null;
    }
    //生产一串流水号
    public static String getFlowingNumber() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String format = sdf.format(new Date());
        Random random = new Random();
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < 4; i++){
            result.append(random.nextInt(100));
        }

//        return System.currentTimeMillis()+""+((int)(Math.random()*100));
        return  format + result;
    }
}
